package com.xq.demo;

public class MovieDao {
    private Movie[] movies;
    public MovieDao(Movie[] movies) {
        this.movies = movies;
    }

    public void printMovie(Movie[] arr) {
        for (int i = 0; i < arr.length; i++) {
            Movie movie = arr[i];
            System.out.println(movie.getId() + " " + movie.getName() + " " + movie.getPrice() + " " + movie.getActor());
        }
    }

    public void queryMovieById(int i) {
        for (int j = 0; j < movies.length; j++) {
            Movie movie = movies[j];
            if (movie.getId() == i) {
                System.out.println("=========");
                System.out.println(movie.getId() + " " + movie.getName() + " " + movie.getPrice() + " " + movie.getActor());
                return;
            }
        }
        System.out.println("没有找到该电影");
    }
}
